#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

const int MAXN = 1001;
int arr[MAXN];
int n;
int first, last;

void quickSort2(int l, int r);
void partition2(int l, int r, int x);
void swap(int i, int j);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    while (cin >> n) {
        for (int i = 0; i < n; i++) {
            cin >> arr[i];
        }
        srand(time(NULL)); // Seed for random number generation
        quickSort2(0, n - 1);
        cout << arr[0];
        for (int i = 1; i < n; i++) {
            cout << " " << arr[i];
        }
        cout << endl;
    }

    return 0;
}

void quickSort2(int l, int r) {
    if (l >= r) {
        return;
    }
    int x = arr[l + rand() % (r - l + 1)];
    partition2(l, r, x);
    int left = first;
    int right = last;
    quickSort2(l, left - 1);
    quickSort2(right + 1, r);
}

void partition2(int l, int r, int x) {
    first = l;
    last = r;
    int i = l;
    while (i <= last) {
        if (arr[i] == x) {
            i++;
        }
        else if (arr[i] < x) {
            swap(first++, i++);
        }
        else {
            swap(i, last--);
        }
    }
}

void swap(int i, int j) {
    int tmp = arr[i];
    arr[i] = arr[j];
    arr[j] = tmp;
}
